﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using DDD_AOP_WCF.Domain;
using DDD_AOP_WCF.Domain.DTO;
using Domain.Core.Specification;
using Infrastructure;
using Project.Caching;

namespace DDD_AOP_WCF.ServiceContracts
{
    [ServiceContract(Namespace = "http://www.ddd_aop_wcf.com")]
    public interface IProductService : IApplicationServiceContract
    {
        /// <summary>
        /// 创建商品信息。
        /// </summary>
        /// <param name="productDataObjects">需要创建的商品信息。</param>
        /// <returns>已创建的商品信息。</returns>
        [OperationContract]
        [FaultContract(typeof(Exception))]
        [Caching(CachingMethod.Remove, "GetProduct", "GetProductByExpression")]
        bool CreateProduct(ProductDTO productDTO);

        /// <summary>
        /// 得到单个实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        [FaultContract(typeof(Exception))]
        [Caching(CachingMethod.Get)]
        ProductDTO GetProductByID(int id);

        /// <summary>
        /// 得到商品
        /// </summary>
        /// <param name="productDataObjects"></param>
        /// <returns></returns>
        [OperationContract]
        [FaultContract(typeof(Exception))]
        [Caching(CachingMethod.Get)]
        List<ProductDTO> GetProduct();

        /// <summary>
        /// 根据条件重到商品列表
        /// </summary>
        /// <param name="predicate"></param>
        /// <returns></returns>
        [OperationContract]
        [FaultContract(typeof(Exception))]
        [Caching(CachingMethod.Get)]
        List<ProductDTO> GetProductByName(string productName);

        /// <summary>
        /// 修改商品
        /// </summary>
        /// <param name="productDTO"></param>
        /// <returns></returns>
        [OperationContract]
        [FaultContract(typeof(Exception))]
        [Caching(CachingMethod.Remove, "GetProduct", "GetProductByExpression")]
        bool ModifyProduct(ProductDTO productDTO);

        /// <summary>
        /// 删除产品
        /// </summary>
        /// <param name="productDTO"></param>
        /// <returns></returns>
        [OperationContract]
        [FaultContract(typeof(Exception))]
        [Caching(CachingMethod.Remove, "GetProduct", "GetProductByExpression")]
        bool DelProduct(int id);

    }
}
